package com.sdleyou.treepro.manager.api.mission;

import com.sdleyou.treepro.common.model.dto.MissionDTO;
import com.sdleyou.treepro.common.model.dto.PropDTO;
import com.sdleyou.treepro.common.model.utils.ResultVOUtil;
import com.sdleyou.treepro.common.model.vo.ResultVO;
import com.sdleyou.treepro.common.service.MissionManager;
import com.sdleyou.treepro.common.service.PropManager;
import com.sdleyou.treepro.system.version.ApiVersion;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 任务控制器
 *
 * @version v1.0
 * 2020年2月22日
 */
@RestController
@RequestMapping("/api")
public class ManagerMissionController {
    @Autowired
    private MissionManager missionManager;

    @ApiVersion(1)
    @PostMapping("/{version}/manager/mission")
    public ResultVO createMission(@RequestBody MissionDTO missionDTO) {
        missionManager.createTask(missionDTO);
        return ResultVOUtil.success();
    }

    @ApiVersion(1)
    @PutMapping("/{version}/manager/mission/{task_id}")
    public ResultVO updateMission(@RequestBody MissionDTO missionDTO,
                               @PathVariable("task_id") String taskId) {
        missionManager.updateTask(missionDTO, taskId);
        return ResultVOUtil.success();
    }

    @ApiVersion(1)
    @PostMapping("/{version}/manager/mission/list")
    public ResultVO createMission() {
        return ResultVOUtil.success(missionManager.getMissionList());
    }
}

